package com.surelution.lansao.wxmp.partner;

import java.util.List;

import com.surelution.lansao.Partner
import com.surelution.lansao.PartnerRequiredOperation
import com.surelution.whistle.core.Attribute


public class PartnerNameRequiredSub extends RequiredBaseSub {

	@Override
	public boolean accept() {
		return true;
	}

	@Override
	public List<Attribute> process() {
		def name = host.getParam(Attribute.KEY_Content)
		if(name) {
			def id = host.partner.id
			Partner p = Partner.get(id)
			p.name = name
			operation.delete()
			
			PartnerRequiredOperation nextOperation = new PartnerRequiredOperation(partner:p, forever:true, className:IdNumberRequiredSub.class.name)
			nextOperation.save()
			return [new Attribute(Attribute.KEY_Content, "请回复您的身份证号")];
		}
		return [new Attribute(Attribute.KEY_Content, "您需要回复您的姓名")];
	}

}
